<?php

require_once ("src/Money.class.php");
require_once ("src/MoneyOps.class.php");
require_once ("src/MoneyExceptions.php");
require_once("src/operationActionClass.php");

class MoneyOpsTestCase extends PHPUnit_Framework_TestCase
{
	private static $f12EUR, $f14EUR, $f26EUR,$f12LIVRE,$f02EUR,$f42DOL,$f12DOL,$f30DOL ;
        public static function setUpBeforeClass() {
		MoneyOpsTestCase::$f12EUR=MoneyFactory::getDefaultFactory()->createMoney(12,"EUR");
        MoneyOpsTestCase::$f12LIVRE=MoneyFactory::getDefaultFactory()->createMoney(12,"LIVRE");
		MoneyOpsTestCase::$f14EUR=MoneyFactory::getDefaultFactory()->createMoney(14,"EUR");
        MoneyOpsTestCase::$f02EUR=MoneyFactory::getDefaultFactory()->createMoney(02,"EUR");
        MoneyOpsTestCase::$f26EUR=MoneyFactory::getDefaultFactory()->createMoney(26,"EUR");
        MoneyOpsTestCase::$f42DOL=MoneyFactory::getDefaultFactory()->createMoney(42,"DOL");
        MoneyOpsTestCase::$f12DOL=MoneyFactory::getDefaultFactory()->createMoney(12,"DOL");
        MoneyOpsTestCase::$f30DOL=MoneyFactory::getDefaultFactory()->createMoney(30,"DOL");

    }

	public function testSimpleEuroAdd() {
        $this->assertTrue(
			MoneyOps::add(
				MoneyOpsTestCase::$f12EUR,
				MoneyOpsTestCase::$f14EUR)
			->equals(MoneyOpsTestCase::$f26EUR)
		);
	}


    public function testSimpleEuroSous() {
        $this->assertTrue(
            MoneyOps::sous(
                MoneyOpsTestCase::$f12EUR,
                MoneyOpsTestCase::$f14EUR)
                ->equals(MoneyOpsTestCase::$f02EUR)
        );
    }

    public function testSimpleDolAdd(){
        $this->assertTrue(
            MoneyOps::add(
                MoneyOpsTestCase::$f12DOL,
                MoneyOpsTestCase::$f30DOL)
                ->equals(MoneyOpsTestCase::$f42DOL)
        );
    }

    public function testIncompatiblesCurrenciesExecption() {
        $this->setExpectedException('IncompatiblesCurrenciesException');

        MoneyOps::add(
                    MoneyOpsTestCase::$f12LIVRE,
                    MoneyOpsTestCase::$f14EUR);

    }

    public function testInvalidOperationException() {
        $this->setExpectedException('InvalidOperationException');
        operationActionClass::index('mult');
    }

}
?>
